package com.bytecodezz.jc.composestate.vm

import androidx.compose.runtime.toMutableStateList
import androidx.lifecycle.ViewModel
import com.bytecodezz.jc.composestate.WellnessTask

class WellnessViewModel : ViewModel() {
    private val _task = getWellnessTasks().toMutableStateList()
    val tasks: List<WellnessTask>
        get() = _task

    fun removeTask(item: WellnessTask) {
        _task.remove(item)
    }

    fun changeTaskChecked(item: WellnessTask, checkState: Boolean) {
        tasks.find { it.id == item.id }?.let { task ->
            task.checked.value = checkState
        }
//        item.checked = checkState
    }

    private fun getWellnessTasks() = List(30) { i -> WellnessTask(id = i, label = "Task # $i") }

}


